package easyzhou.com.ui;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * 中间的画板
 * 
 * @author mjorcen
 *
 */
public class EastPanel extends JPanel {
	/**
		 * 
		 */
	private static final long serialVersionUID = 372557751292100475L;
	private JFrame parent;
	private JButton button;

	private EastPanel(JFrame parent) {
		this.parent = parent;
	}

	private void init() {
		setSize(200, 500);
		setBackground(Color.lightGray);
		button = new JButton(12 + "");
		setBackground(Color.GRAY); // 将JPanel的实例背景设置为黄色
		GridBagLayout gridLayout = new GridBagLayout();
		setLayout(gridLayout);
		add(button);
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
		// 是用来控制添加进的组件的显示位置
		gridBagConstraints.fill = gridBagConstraints.BOTH;
		{
			gridBagConstraints.insets = new Insets(1, 1, 1, 1);
			gridBagConstraints.gridwidth = 1;// 该方法是设置组件水平所占用的格子数，如果为0，就说明该组件是该行的最后一个
			gridBagConstraints.weightx = 1;// 第一列的分布方式为10%
			gridBagConstraints.weighty = 1;// 该方法设置组件垂直的拉伸幅度，如果为0就说明不拉伸，不为0就随着窗口增大进行拉伸，0到1之间
			gridLayout.setConstraints(button, gridBagConstraints);// 设置组件
		}
	}

	public static final EastPanel newInstance(JFrame frame) {
		EastPanel panel = new EastPanel(frame); // 创建一个JPanel的实例
		panel.init();
		return panel;
	}
}
